home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
oop_tp55.zip
/
LIST5_2A.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1980-01-07
|
2KB
|
69 lines
program Listing5_2A;
type
Elf = object
Name : string;
constructor Init( Monicker : string );
procedure ShopScript; virtual;
procedure GoShopping;
end;
VirtualElf = object( Elf )
procedure ShopScript; virtual;
end;
constructor Elf.Init( Monicker : string );
begin
Name := Monicker;
end;
procedure Elf.ShopScript;
begin
writeln( '<Door slams as ', Name, ' leaves>');
writeln( '<long pause.......>' );
writeln( '<Door slams as ', Name, ' returns>');
writeln( Name,
': I went to the store and bought milk and eggs.');
end;
procedure Elf.GoShopping;
begin
ShopScript;
end;
procedure VirtualElf.ShopScript;
var
ShoppingList : string;
begin
writeln( Name,
': When I get to the store, I''ll call you.');
writeln( '<Door slams as ', Name, ' leaves>');
writeln( '<pause.......>' );
writeln( 'PHONE: Brrring!');
writeln( '<pick up phone>' );
writeln( 'YOU: Hello?' );
writeln( Name, ': Hi. What do you want me to buy?' );
write( 'YOU (enter something): ');
readln( ShoppingList );
writeln( Name, ': Gotcha. Bye.');
writeln( '<hang up phone>' );
writeln( '<pause.......>' );
writeln( '<Door slams as ', Name, ' returns>');
writeln( Name, ': As you requested, I bought: ',
ShoppingList );
end;
var
Jay : Elf;
Ray : VirtualElf;
begin
Jay.Init( 'JAY' );
Ray.Init( 'RAY' );
Jay.GoShopping;
Ray.GoShopping;
end.
{ end of Listing 5-2A }